GHashTable *keyed_cache; /* char * -> ClutterImage* */
GHashTable *keyed_surface_cache; /* char * -> cairo_surface_t* */
+ GHashTable *used_scales; /* Set: double */
+
/* Presently this is used to de-duplicate requests for GIcons and async URIs. */
GHashTable *outstanding_requests; /* char * -> AsyncTextureLoadData * */
g_str_equal,
g_free,
(GDestroyNotify) cairo_surface_destroy);
+ self->priv->used_scales = g_hash_table_new (g_double_hash, g_double_equal);
self->priv->outstanding_requests = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
self->priv->file_monitors = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
g_clear_pointer (&self->priv->keyed_cache, g_hash_table_destroy);
g_clear_pointer (&self->priv->keyed_surface_cache, g_hash_table_destroy);
+ g_clear_pointer (&self->priv->used_scales, g_hash_table_destroy);
g_clear_pointer (&self->priv->outstanding_requests, g_hash_table_destroy);
g_clear_pointer (&self->priv->file_monitors, g_hash_table_destroy);
return actor;
}
+static void
+hash_table_remove_with_scales (GHashTable *hash,
+ GList *scales,
+ const char *base_key)
+{
+ GList *l;
+
+ for (l = scales; l; l = l->next)
+ {
+ double scale = *((double *)l->data);
+ g_autofree char *key = NULL;
+ key = g_strdup_printf ("%s%f", base_key, scale);
+ g_hash_table_remove (hash, key);
+ }
+}
+
static void
file_changed_cb (GFileMonitor *monitor,
GFile *file,
StTextureCache *cache = user_data;
char *key;
guint file_hash;
+ g_autoptr (GList) scales = NULL;
if (event_type != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
return;
file_hash = g_file_hash (file);
+ scales = g_hash_table_get_keys (cache->priv->used_scales);
key = g_strdup_printf (CACHE_PREFIX_FILE "%u", file_hash);
g_hash_table_remove (cache->priv->keyed_cache, key);
+ hash_table_remove_with_scales (cache->priv->keyed_cache, scales, key);
g_free (key);
key = g_strdup_printf (CACHE_PREFIX_FILE_FOR_CAIRO "%u", file_hash);
g_hash_table_remove (cache->priv->keyed_surface_cache, key);
+ hash_table_remove_with_scales (cache->priv->keyed_surface_cache, scales, key);
g_free (key);
g_signal_emit (cache, signals[TEXTURE_FILE_CHANGED], 0, file);
goto out;
if (policy == ST_TEXTURE_CACHE_POLICY_FOREVER)
- g_hash_table_insert (cache->priv->keyed_cache, g_strdup (key), image);
+ {
+ g_hash_table_insert (cache->priv->keyed_cache, g_strdup (key), image);
+ g_hash_table_insert (cache->priv->used_scales, &resource_scale, &resource_scale);
+ }
}
/* Because the texture is loaded synchronously, we won't call
cairo_surface_reference (surface);
g_hash_table_insert (cache->priv->keyed_surface_cache,
g_strdup (key), surface);
+ g_hash_table_insert (cache->priv->used_scales, &resource_scale, &resource_scale);
}
}
else